package com.woniuxy02;

public class Test02 {
    public static void main(String[] args) {
//        String str="012340";
//        boolean flag=validateString(str);
//        System.out.println(flag);
//        String reg="^[1-9]\\d{4,14}$";
//        System.out.println(str.matches(reg));

        String emailReg="^\\w+@\\w+\\.\\w+$";
        String email="abcd@qq.com";
        System.out.println(email.matches(emailReg));
        System.out.println(email.matches("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"));

    }

    private static boolean validateString(String str) {
        //校验字符串格式，要求：必须是5-15位数字；0不能开头
        if(str.length()<5||str.length()>15){
            return false;
        }
        if(str.charAt(0)=='0'){
            return false;
        }
        char[] chars = str.toCharArray();
        for(char c : chars){
            if(!(c>='0' && c<='9')){
                return false;
            }
        }
        return true;
    }
}
